<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>认款列表 管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="btnsBox">
                    <span id="confirmBtn" class="sq-button sq-button-round">批量认款</span>
                </div>
            </div>
        </form>
    </div>

    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null, resultGrid = null;
    var callback = null;
    $(function () {
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/capital/capFund/initList.do?type=1',
            parms:{ascrCd:0},
            method: 'get',
            columns: [
                {display: '资金编号', name: 'code', minWidth: 130, align: 'center', enabledSort: false},
                {display: '收款账户', name: 'acceptName', minWidth: 100, align: 'left', enabledSort: false},
                {display: '来款账户', name: 'comeName', minWidth: 100, align: 'center', enabledSort: false},
                /*{display: '来款账号', name: 'comeCode', minWidth: 100, align: 'center', enabledSort: false},*/
                {display: '来款金额', name: 'amount', minWidth: 100, align: 'right', enabledSort: false,
                    render:function(rowdata,index,value){
                        return FormatMoney(rowdata.amount/100);
                    }
                },
                {display: '摘要', name: 'docketRem', minWidth: 130, align: 'left', enabledSort: false},
                {display: '到账日期', name: 'acceptDate', minWidth: 100, align: 'center', enabledSort: false,render:renderDate2},
                {display: '导入日期', name: 'crtTm', minWidth: 130, align: 'center', enabledSort: false,render:renderDate},
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: false,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: true
        });
        grid.setHeight(100);

        $("#searchBar").ligerForm();

        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            $("#resetBtn").click();  //重置 input-text
            var form = liger.get("searchBar");
            form.setData({  //重置select等特殊表单
                "*Cd": " "
            });
        });
        
        callback = function () {
            grid.reload();
        };

        /* 批量认款 */
        $("#confirmBtn").click(function (event) {
            /*var selectedRows = grid.getSelectedRows();
            if (selectedRows.length == 0) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_MORE_ROW, SQ_type: "warning"});
                return;
            }
            var _ids = [];
            for (var index in selectedRows) {
                _ids.push(selectedRows[index].id);
            }*/

            //top.$.ligerDialog.confirm("是否确认执行批量认款?", function (flag) {
            //    if (flag == false)return;
                var wait_dialog;
                $.ajax({
                    url: '<%=path%>/capital/capFund/batchConfirmFund.do',
                    type: 'post',
                    dataType: 'json',
                    //data: {ids: JSON.stringify(_ids)},
                    beforeSend: function () {
                        wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING,SQ_type: "waitting"});
                    },
                    success: function (msg) {
                        wait_dialog.close();
                        $.ligerDialog.open({
                            cls: 'noBorder_Dialog',
                            width: 800,
                            height: 450,
                            title: '批量认款结果',
                            url: '<%=path%>/capital/capFund/toConfirmResultPage.do',
                            myDataName: msg.data
                        });

                        /*if (msg.success == 1) {
                            top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                            grid.reload();
                        } else {
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                        }*/
                    }
                });
            //});
        });

    });

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }
    //格式化时间
    function renderDate2(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }

</script>

</body>
</html>
